"""
管理所有的strategy service,可以通过此类获取制定strategy
"""
from strategy.strategy_factory import StrategyFactory


class StrategyManager:
    def __init__(self, config):
        self._service_map = {}
        for conf in config:
            self._service_map[conf["name"]] = conf

    def get_service(self, name):
        """
        根据query analyse name ,调用 query analyse factory 构建
        :return:
        """
        if name not in self._service_map:
            print("strategy service name %s not found in service_map" % name)
            return None
        conf = self._service_map[name]
        service = StrategyFactory.create_service(conf)
        return service
